# vim: set ft=sh:

install ()
{
    if [ -z "${CRYPTO_MODULES}" ]; then
        MODULES=" dm-crypt $(all_modules "/crypto/") "
    else
        MODULES=" dm-crypt ${CRYPTO_MODULES} "
    fi
    FILES=""
    SCRIPT="encrypt"
    add_dir "/dev/mapper"
    if [ -f "${BASEDIR}/sbin/cryptsetup" ]; then
		add_file "${BASEDIR}/sbin/cryptsetup" "/sbin/cryptsetup"
		SO="libcryptsetup.so libpopt.so libdevmapper.so libgcrypt.so libgpg-error.so libudev.so"
		for so in $SO; do
			for file in $(ls -1 ${BASEDIR}/lib/$so* 2>/dev/null); do
				add_file "${file}" "${file##$BASEDIR}"
			done
		done
    fi
    if [ -f "${BASEDIR}/usr/sbin/cryptsetup" ]; then
		add_file "${BASEDIR}/usr/sbin/cryptsetup" "/sbin/cryptsetup"
		SO="libcryptsetup.so libpopt.so libdevmapper.so libgcrypt.so libgpg-error.so libudev.so"
		for so in $SO; do
			for file in $(ls -1 ${BASEDIR}/usr/lib/$so* 2>/dev/null); do
				add_file "${file}" "${file##$BASEDIR}"
			done
		done
    fi

    add_file "${BASEDIR}/sbin/dmsetup" "/sbin/dmsetup"
    SO="libdevmapper.so libudev.so"
    for so in $SO; do
		for file in $(ls -1 ${BASEDIR}/usr/lib/$so* 2>/dev/null); do
			add_file "${file}" "${file##$BASEDIR}"
		done
    done

    add_file "/lib/udev/rules.d/10-dm.rules"
    add_file "/lib/udev/rules.d/13-dm-disk.rules"
    add_file "/lib/udev/rules.d/95-dm-notify.rules"
}

help ()
{
cat<<HELPEOF
  This hook allows for an encrypted root device.
HELPEOF
}
